#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QIcon icon(":/test.jpg");
    this->setWindowIcon(icon);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QRect rect = ui->label->geometry();
    ui->label->setGeometry(rect.x(), rect.y()-5, rect.width(), rect.height());
}

void Widget::on_pushButton_2_clicked()
{
    QRect rect = ui->label->geometry();
    ui->label->setGeometry(rect.x(), rect.y()+5, rect.width(), rect.height());
}


void Widget::on_pushButton_4_clicked()
{
    QRect rect = ui->label->geometry();
    if(rect.x() <= 0) rect.setX(0);
    else rect.setX(rect.x()-30);
    qDebug() << rect;
    ui->label->setGeometry(rect.x(), rect.y(), rect.width()-30, rect.height());
}

void Widget::on_pushButton_3_clicked()
{
    QRect rect = ui->label->geometry();
    int w = this->geometry().width();
    int wl = ui->label->geometry().width();
    if(rect.x() >= w-rect.width())
    {

        rect.setX(w-rect.width());
        rect.setWidth(wl);
    }
    else
    {
        rect.setX(rect.x()+30);
        rect.setWidth(wl);
    }
    qDebug() << rect;

    ui->label->setGeometry(rect);
}
